// import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'
import OrderList from '@/components/orderManagement/orderList'
import OrderDataStatistics from '@/components/orderManagement/orderDataStatistics'
import OrderDetail from '@/components/orderManagement/orderDetail'
import OrderExport from '@/components/orderManagement/orderExport'
import OperatingReport from '@/components/orderManagement/operatingReport'
import UserList from '@/components/user/userList'
import AddUser from '@/components/user/addUser'
import EditUser from '@/components/user/editUser'
import GoodsList from '@/components/goods/goodsList'
import ImportGoods from '@/components/goods/importGoods'
import AddGoods from '@/components/goods/addGoods'
import EditGoods from '@/components/goods/editGoods'
import DepotList from '@/components/agent/depotList'
import AddDepot from '@/components/agent/addDepot'
import EditDepot from '@/components/agent/editDepot'
import DepotManage from '@/components/agent/depotManage'
import ActivityList from '@/components/activityManagement/activityList'
import AddActivity from '@/components/activityManagement/addActivity'
import EditActivity from '@/components/activityManagement/editActivity'
import ActivityGoodsList from '@/components/activityManagement/activityGodsList'
import BrandList from '@/components/brand/brandList'
import AddBrand from '@/components/brand/addBrand'
import EditBrand from '@/components/brand/editBrand'
import UserCodeList from '@/components/codeManage/userCodeList'
import BannerList from '@/components/brand/bannerList'
import EditBanner from '@/components/brand/editBanner'
import AddBanner from '@/components/brand/addBanner'
import CouponList from '@/components/couponManagement/couponList'
import AddCoupon from '@/components/couponManagement/addCoupon'
import EditCoupon from '@/components/couponManagement/editCoupon'
import ChannelList from '@/components/channelManagement/channelList'
import AddChannel from '@/components/channelManagement/addChannel'
import EditChannel from '@/components/channelManagement/editChannel'
import GiftPackList from '@/components/giftPack/giftPackList'
import AddGiftPack from '@/components/giftPack/addGiftPack'
import EditGiftPack from '@/components/giftPack/editGiftPack'
import VideoList from '@/components/videoManagement/videoList'
import AddVideo from '@/components/videoManagement/addVideo'
import EditVideo from '@/components/videoManagement/editVideo'
import CustomerList from '@/components/customerManagement/customerList'
import EditCustomer from '@/components/customerManagement/editCustomer'
import ActivityCustomer from '@/components/customerManagement/activityCustomer'
import CheckCustomer from '@/components/customerManagement/checkCustomer'
import CommissionList from '@/components/commission/commissionList'

// Vue.use(Router)

let router = new Router({
    // mode: 'history',
    // base: '/ddaigo-management',
    routes: [{
            // 登录
            path: '/',
            redirect: '/login'
        },
        {
            // 登录
            id: '1',
            path: '/login',
            name: 'login',
            component: Login,
            meta: {
                title: '登录'
            }
        },
        {
            // 订单列表
            id: '2',
            path: '/orderList',
            name: 'orderList',
            component: OrderList,
            meta: {
                title: '订单列表'
            }
        },
        {
            // 订单统计列表
            path: '/orderDataStatistics',
            name: 'orderDataStatistics',
            component: OrderDataStatistics,
            meta: {
                title: '订单统计'
            }
        },
        {
            // 订单导出
            path: '/orderExport',
            name: 'orderExport',
            component: OrderExport,
            meta: {
                title: '订单导出'
            }
        },
        {
            // 编辑订单
            path: '/orderDetail',
            name: 'orderDetail',
            component: OrderDetail,
            meta: {
                title: '订单详情'
            }
        },
        {
            // 用户列表
            path: '/userList',
            name: 'userList',
            component: UserList,
            meta: {
                title: '用户列表'
            }
        },
        // 添加用户
        {
            path: '/addUser',
            name: 'addUser',
            component: AddUser,
            meta: {
                title: '添加用户'
            }
        },
        // 编辑用户
        {
            path: '/editUser/:id',
            name: 'editUser',
            component: EditUser,
            meta: {
                title: '编辑用户'
            }
        },
        //商品列表
        {
            path: '/goodsList',
            name: 'goodsList',
            component: GoodsList,
            meta: {
                title: '商品列表'
            }
        },
        //导入商品
        {
            path: '/importGoods',
            name: 'importGoods',
            component: ImportGoods,
            meta: {
                title: '导入商品'
            }
        },
        //添加商品
        {
            path: '/addGoods',
            name: 'addGoods',
            component: AddGoods,
            meta: {
                title: '添加商品'
            }
        },
        //编辑商品
        {
            path: '/editGoods/:id',
            name: 'editGoods',
            component: EditGoods,
            meta: {
                title: '编辑商品'
            }
        },
        //仓库列表
        {
            path: '/depotList',
            name: 'depotList',
            component: DepotList,
            meta: {
                title: '仓库列表'
            }
        },
        //仓库管理
        {
            path: '/depotManage',
            name: 'depotManage',
            component: DepotManage,
            meta: {
                title: '仓库管理'
            }
        },
        //添加仓库
        {
            path: '/addDepot',
            name: 'addDepot',
            component: AddDepot,
            meta: {
                title: '添加仓库'
            }
        },
        //编辑仓库
        {
            path: '/editDepot/:id',
            name: 'editDepot',
            component: EditDepot,
            meta: {
                title: '编辑仓库'
            }
        },
        //活动列表
        {
            path: '/activityList',
            name: 'activityList',
            component: ActivityList,
            meta: {
                title: '活动列表'
            }
        },
        //新增活动
        {
            path: '/addActivity',
            name: 'addActivity',
            component: AddActivity,
            meta: {
                title: '新增活动'
            }
        },
        //编辑活动
        {
            path: '/editActivity/:id',
            name: 'editActivity',
            component: EditActivity,
            meta: {
                title: '编辑活动'
            }
        },
        //查看活动商品列表
        {
            path: '/activityGodsList/:id',
            name: 'activityGodsList',
            component: ActivityGoodsList,
            meta: {
                title: '活动商品列表'
            }
        },
        //品牌列表
        {
            path: '/brandList',
            name: 'brandList',
            component: BrandList,
            meta: {
                title: '品牌列表'
            }
        },
        //添加品牌
        {
            path: '/addBrand',
            name: 'addBrand',
            component: AddBrand,
            meta: {
                title: '新增品牌'
            }
        },
        //编辑品牌
        {
            path: '/editBrand/:id',
            name: 'editBrand',
            component: EditBrand,
            meta: {
                title: '编辑品牌'
            }
        },
        //邀请码列表
        {
            path: '/userCodeList',
            name: 'userCodeList',
            component: UserCodeList,
            meta: {
                title: '用户邀请码列表'
            }
        },
        //轮播列表
        {
            path: '/bannerList',
            name: 'bannerList',
            component: BannerList,
            meta: {
                title: '轮播列表'
            }
        },
        //添加轮播
        {
            path: '/addBanner',
            name: 'addBanner',
            component: AddBanner,
            meta: {
                title: '添加轮播'
            }
        },
        //编辑轮播
        {
            path: '/editBanner/:id',
            name: 'editBanner',
            component: EditBanner,
            meta: {
                title: '编辑轮播'
            }
        },
        //优惠券列表
        {
            path: '/couponList',
            name: 'couponList',
            component: CouponList,
            meta: {
                title: '优惠券'
            }
        },
        //添加优惠券
        {
            path: '/addCoupon',
            name: 'addCoupon',
            component: AddCoupon,
            meta: {
                title: '添加优惠券'
            }
        },
        {
            path: '/editCoupon/:id',
            name: 'editCoupon',
            component: EditCoupon,
            meta: {
                title: '编辑优惠券'
            }
        },
        //渠道列表
        {
            path: '/channelList',
            name: 'channelList',
            component: ChannelList,
            meta: {
                title: '渠道列表'
            }
        },
        //新增渠道
        {
            path: '/addChannel',
            name: 'addChannel',
            component: AddChannel,
            meta: {
                title: '添加渠道'
            }
        },
        //编辑渠道
        {
            path: '/editChannel/:id',
            name: 'editChannel',
            component: EditChannel,
            meta: {
                title: '编辑渠道'
            }
        },
        //代购礼包列表
        {
            path: '/giftPackList',
            name: 'giftPackList',
            component: GiftPackList,
            meta: {
                title: '代购礼包列表'
            }
        },
        //新增代购礼包
        {
            path: '/addGiftPack',
            name: 'addGiftPack',
            component: AddGiftPack,
            meta: {
                title: '新增代购礼包'
            }
        },
        //编辑代购礼包
        {
            path: '/editGiftPack/:id',
            name: 'editGiftPack',
            component: EditGiftPack,
            meta: {
                title: '新增代购礼包'
            }
        },
        //视频列表
        {
            path: '/videoList',
            name: 'videoList',
            component: VideoList,
            meta: {
                title: '视频列表'
            }
        },
        //添加视频
        {
            path: '/addVideo',
            name: 'addVideo',
            component: AddVideo,
            meta: {
                title: '添加视频'
            }
        },
        //编辑视频
        {
            path: '/editVideo/:id',
            name: 'editVideo',
            component: EditVideo,
            meta: {
                title: '编辑视频'
            }
        },
        //客户端用户列表
        {
            path: '/customerList',
            name: 'customerList',
            component: CustomerList,
            meta: {
                title: '客户端用户列表'
            }
        },
        //客户端用户编辑
        {
            path: '/editCustomer/:id',
            name: 'editCustomer',
            component: EditCustomer,
            meta: {
                title: '编辑用户'
            }
        },
        //获取申请提现记录列表
        {
            path: '/commissionList',
            name: 'commissionList',
            component: CommissionList,
            meta: {
                title: '申请提现列表'
            }
        },
        //非普通用户列表
        {
            path: '/activityCustomer',
            name: 'activityCustomer',
            component: ActivityCustomer,
            meta: {
                title: '活动用户'
            }
        },
        //非普通用户列表
        {
            path: '/checkCustomer/:id',
            name: 'checkCustomer',
            component: CheckCustomer,
            meta: {
                title: '直属会员'
            }
        },
         //运营报表
         {
            path: '/operatingReport',
            name: 'operatingReport',
            component: OperatingReport,
            meta: {
                title: '运营报表'
            }
        },
        {
            path: '*',
            redirect: '/',
            hidden: true
        }
    ]
})

router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
        document.title = to.meta.title
        document.body.scrollTop = document.documentElement.scrollTop = 0
    }
    // console.log(localStorage.user.sessionId)
    if (!localStorage.getItem('ddaigoUser') && to.name !== 'login') {
        return next('/login')
    }
    next()
})

export default router
